﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FilterEmoji : MonoBehaviour
{
    public InputField input;

    private void Start()
    {
        if (input)
        {
            input.onValueChanged.AddListener(delegate { OnValueChange(); });
        }
    }
    public void OnValueChange()
    {
        if (input)
        {
            input.text = FilterEmojiFunc(input.text);
        }
    }

    List<string> _emojiPatten = new List<string>() { @"\p{Cs}", @"\p{Co}", @"\p{Cn}", @"[\u2702-\u27B0]" };
    public string FilterEmojiFunc(string str)
    {
        for (int i = 0; i < _emojiPatten.Count; i++)
        {
            str = System.Text.RegularExpressions.Regex.Replace(str, _emojiPatten[i], "");
        }
        return str;
    }
}
